package com.maxd.modules.syslog.controller;

import com.maxd.adapter.IgnoreSecurity;
import com.maxd.error.Result;
import com.maxd.modules.syslog.entity.RequestLogs;
import com.maxd.modules.syslog.service.RequestLogsService;
import com.maxd.modules.syslog.utils.RequestLogsUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: Laban:yubo_010@163.com
 * @Date: 2020/11/18 10:15
 * @Description:
 */
@RestController
@Api(value="API请求日志管理",tags={"API请求日志管理"})
@RequestMapping(value = "/requestLogs")
public class RequestLogsController {

    private final static Logger log = LoggerFactory.getLogger(RequestLogsController.class);


    @Autowired
    private RequestLogsService requestLogsService;

    RequestLogsUtil requestLogsUtil = new RequestLogsUtil();

    /**
     * 根据条件 分页查询
     */
    @RequestMapping(value = "/findAllRequestLogs", method = RequestMethod.POST)
    @ApiOperation("分页查询API请求日志")
    //@IgnoreSecurity
    public Result findAllRequestLogs(@RequestBody RequestLogs requestLogs, @RequestParam Integer page, @RequestParam int size) {
        RequestLogs requestLogs1 = requestLogsUtil.copyNull(requestLogs);
        Pageable pageable = PageRequest.of(page, size);
        return requestLogsService.findAll(requestLogs1,pageable);
    }

}
